<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>市平台财务统计管理</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready( function() {
	//$("#name").focus();
		$("#inputForm").validate({
			submitHandler : function(form) {
				postForm(form);
			},
			errorContainer : "#messageBox",
			errorPlacement : function(error, element) {
				$("#messageBox").text("输入有误，请先更正。");
				if (element.is(":checkbox")
						|| element.is(":radio")
						|| element.parent().is(
								".input-append")) {
					error.appendTo(element.parent()
							.parent());
				} else {
					error.insertAfter(element);
				}
			}
		});

		$("#area").click(function() {
			var url = "${ctx }/area/areaChoose/area";
			layer.open({
				type : 2,
				title : '',
				shadeClose : true,
				shade : 0.8,
				area : [ '800px', '500px' ],
				content : url
			});
		});
		//出入库单/欠款不给修改payType
		cssPayType();
	});

	function setReceive(str, code, type, id, parentIds, grade) {
		$("#receiveorgName").val(str);
		$("#receiveorgCode").val(code);
	}
	
	function cssPayType(){
		if(${bsReportPay.type == '1'}){
			$("#payType").attr("disabled","true");
		}
	}
	
	function postForm(form) {//表单保存时  将此方法中的数据尽行保存
        var payment = $("#payment").val();
        var payment_reg = /^\d+(\.\d+)?$/;
		if (!payment_reg.test(payment)) {
			layer.msg('金额不合法', { icon: 2});
			return false;
		}
		
		layer.confirm('确定保存？', {
			btn : [ '保存', '取消' ]
		}, function() {
			layer.load(2);
			loading('正在提交，请稍等...');
			form.submit();
		});
	}
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/report/bsReportPay/list">出入库账单列表</a></li>
		<shiro:hasPermission name="report:bsReportPay:edit">
		<li class="active"><a href="">建账${not empty bsReportPay.id?'修改':''} </a></li>
		</shiro:hasPermission>
	</ul>
	<br />
	<form:form id="inputForm" modelAttribute="bsReportPay"
		action="${ctx}/report/bsReportPay/save" method="post"
		class="form-horizontal">
		<form:hidden path="id" />
		<form:hidden path="type" id="type"/>
		<sys:message content="${message}" />
		<div class="control-group">
			<label class="control-label">收款单位：</label>
			<div class="controls">
				<sys:treeselect2 id="supplyorgCode" name="supplyorgCode" value="${bsReportPay.supplyorgCode}" labelName="supplyorgName" labelValue="${bsReportPay.supplyorgName}"
						title="部门" url="/sys/office/treeData2?areaType=3" cssClass="input-xlarge-search" allowClear="true" notAllowSelectParent="true"/>
				<%-- <form:input path="supplyorgName"  readonly="true" htmlEscape="false" maxlength="255" class="input-xlarge required"/> --%>
				<label hidden="true"  class="error" data="update"></label>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><font color="red">*</font> 欠款/回款 单位：</label>
			<div class="controls">
				<sys:treeselect2 id="receiveorgCode" name="receiveorgCode" value="${bsReportPay.receiveorgCode}" labelName="receiveorgName" labelValue="${bsReportPay.receiveorgName}"
						title="部门" url="/sys/office/treeData" cssClass="input-xlarge-search" allowClear="true" notAllowSelectParent="true"/>
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">sum_orignprice：</label>
			<div class="controls">
				<form:input path="sumOrignprice" htmlEscape="false" maxlength="18" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">sum_sellprice：</label>
			<div class="controls">
				<form:input path="sumSellprice" htmlEscape="false" maxlength="18" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">类型：</label>
			<div class="controls">
				<form:select path="type" id="type" class="input-xlarge">
					<form:options items="${fns:getDictList('pay_order_type')}"
						itemLabel="label" itemValue="value" htmlEscape="false" />
				</form:select>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label"><font color="red">*</font> 欠款/回款：</label>
			<div class="controls">
				<form:select path="payType" id="payType"  class="input-xlarge required">
					<form:option value="" label="--请选择--" />
					<form:options items="${fns:getDictList('pay_type')}"
						itemLabel="label" itemValue="value" htmlEscape="false" />
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><font color="red">*</font> 金额：</label>
			<div class="controls">
				<form:input path="payment" htmlEscape="false" maxlength="18" class="input-xlarge required"/>
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">关联出库单：</label>
			<div class="controls">
				<form:input path="orderNo" readonly="true" htmlEscape="false" maxlength="32" class="input-xlarge "/>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label"><font color="red">*</font> 日期：</label>
			<div class="controls">
				<input name="payDate" id="payDate" type="text" maxlength="20" class="Wdate input-xlarge required" readonly
					value="<fmt:formatDate value="${bsReportPay.payDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" />
				<%-- <input name="payDate" id="payDate" type="text" maxlength="20"
					class="Wdate input-xlarge required" 
					value="<fmt:formatDate value="${bsReportPay.payDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});" /> --%>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4"
					maxlength="255" class="input-xxlarge" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="report:bsReportPay:edit">
				<input id="btnSubmit" class="btn btn-primary" type="submit"
					value="保 存" />&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)" />
		</div>
	</form:form>
</body>
</html>